#ifndef RENDER_H
#define RENDER_H

#include "text_layout.h"
#include "unicode.h"

/// Options controlling how items are rendered to wxTextCtrl.
struct RenderOptions {
    bool show_keyword_marks;
    bool show_unknown_keywords;
    bool show_sources;
    bool collapse;
    bool highlight;
    wxString highlight_body;
    vector<wxString> highlight_keywords;
};

class wxTextCtrl;
class wxTextAttr;

/// Common structure for items that NotesPanelBase can display.
/// Auto-checks whether proper type of item is accessed
class TextItem
{
public:
    enum TYPE {INFO, NOTE, KEYWORD};

    TextItem(const wxString& i) {_type = INFO;    _info    = i;}
    TextItem(const Note& n)     {_type = NOTE;    _note    = n;}
    TextItem(const Keyword& k)  {_type = KEYWORD; _keyword = k;}

    TYPE type() const {wxASSERT(_type>=INFO && _type<=KEYWORD); return _type;}
    bool isInfo() const {return type() == INFO;}
    bool isNote() const {return type() == NOTE;}
    bool isKeyword() const {return type() == KEYWORD;}

    wxString& info()    {wxASSERT(_type == INFO);    return _info;}
    Note&     note()    {wxASSERT(_type == NOTE);    return _note;}
    Keyword&  keyword() {wxASSERT(_type == KEYWORD); return _keyword;}
    const wxString& info()    const {wxASSERT(_type == INFO);    return _info;}
    const Note&     note()    const {wxASSERT(_type == NOTE);    return _note;}
    const Keyword&  keyword() const {wxASSERT(_type == KEYWORD); return _keyword;}

    void Render(wxTextCtrl* textctrl, const RenderOptions& opt) const;
    wxString ToString() const;

private:
    TYPE _type;
    wxString _info;
    Note     _note;
    Keyword  _keyword;
    void RenderNote(wxTextCtrl* textctrl, const RenderOptions& opt) const;
    void RenderLayout(wxTextCtrl* textctrl, TextLayout layout, const RenderOptions& opt) const;
};

#endif
